# author: dcc

import requests
from utils.common_dcc import response_time, headerAdmin
from utils.environments_json import urlHead


# /commentapi/comment/front/scoringComment（查看题目下的题目评论列表）
# topic_type:1客观题，2主观题
def comment_list(uri: str, body: dict, need_reply: int, num_id: int, topic_type: int, topic_id: int, question_id,
                 session):
    url = urlHead+uri
    body["needReply"] = need_reply
    body["id"] = num_id
    body["topicQO"] = {"topicType": topic_type, "topicId": topic_id, "questionId": question_id}
    res = session.post(url=url, json=body)
    response_time(url=url, res=res)
    return res


# /commentapi/comment/front/add（新增题目评论）
# topic_type:1客观题，2主观题
def add_comment(uri: str, body: dict, topic_type: int, topic_id: int, question_id, session, **kwargs):
    url = urlHead+uri
    body["topicQO"] = {"topicType": topic_type, "topicId": topic_id, "questionId": question_id}
    body.update(kwargs)
    res = session.post(url=url, json=body)
    response_time(url=url, res=res)
    return res


# /commentapi/commentLike/front/like（对评论点赞）
def like_comment(uri: str, comment_id: int, session):
    url = urlHead+uri
    body = {"id": comment_id}
    res = session.post(url=url, json=body)
    response_time(url=url, res=res)
    return res


# /commentapi/comment/front/scoringReply（查看评论的回复详情）
def reply_list(uri: str, body: dict, num_id: int, parent_id: int, topic_type: int, topic_id: int, question_id, session):
    url = urlHead+uri
    body["id"] = num_id
    body["parentId"] = parent_id
    body["topicQO"] = {"topicType": topic_type, "topicId": topic_id, "questionId": question_id}
    res = session.post(url=url, json=body)
    response_time(url=url, res=res)
    return res


# /commentapi/comment/review（管理后台审核题目评论）
def comment_review(uri: str, body: dict):
    url = urlHead+uri
    res = requests.post(url=url, json=body, headers=headerAdmin)
    response_time(url=url, res=res)
    return res


# /commonapi/stationLetterRecord/front/page（站内信系统消息列表）
def letter_list(uri: str, body: dict, session):
    url = urlHead+uri
    res = session.post(url=url, json=body)
    response_time(url=url, res=res)
    return res


# /commentapi/commentTag/front/list（举报标签列表）
def tag_list(uri: str):
    url = urlHead+uri
    res = requests.get(url=url, headers=headerAdmin)
    response_time(url=url, res=res)
    return res


# /commentapi/commentTag/add（添加举报标签）
def add_tag(uri: str, body: dict):
    url = urlHead+uri
    res = requests.post(url=url, json=body, headers=headerAdmin)
    response_time(url=url, res=res)
    return res


# /commentapi/commentReportRecord/front/report（评论/回复内容举报）
def report_comment(uri: str, body: dict, comment_id: int, tag_id: int, session):
    url = urlHead+uri
    body["commentId"] = comment_id
    body["tagId"] = tag_id
    res = session.post(url=url, json=body)
    response_time(url=url, res=res)
    return res


# /commentapi/commentReportRecord/deleteComment（举报审核通过，删除内容）
def delete_comment(uri: str, body: dict):
    url = urlHead + uri
    res = requests.post(url=url, json=body, headers=headerAdmin)
    response_time(url=url, res=res)
    return res
